package xin.xihc.jba.sql.clause;

import xin.xihc.jba.sql.KV;

/**
 * is null or is not null
 *
 * @author Leo.Xi
 * @date 2020/4/15
 * @since 1.0
 **/
public class IsNull extends Clause<Boolean> {

    public IsNull(String columnName, Boolean isNull) {
        super(columnName, isNull);
    }

    @Override
    public Boolean value() {
        if (this.value == null) {
            return false;
        }
        return this.value;
    }

    @Override
    public String operation() {
        return " IS ";
    }

    @Override
    public String toSql(KV kv) {
        return this.columnName + this.operation() + (this.value ? "NULL" : "NOT NULL");
    }

}
